/* file pki.c
 * public key encrypt/decrypt
 *
 * neil duan
 * 2008-6
 */

#include "nd_app.h"
#include "nd_crypt/nd_crypt.h"

static NDINT8 __rsa_digest[16] ;
ND_RSA_CONTEX  __rsa_contex ;

NDINT32 create_rsa_key()
{
	if(nd_RSAInit(&__rsa_contex))
		return -1 ;

	MD5Crypt16((NDINT8*)&(__rsa_contex.publicKey), sizeof(R_RSA_PUBLIC_KEY ) , __rsa_digest);
	//MD5ToString(__rsa_digest, md5text);
	//NDTRACF("RSA text=[%s]",md5text);
	return 0 ;
}

void destroy_rsa_key()
{
	nd_RSAdestroy(&__rsa_contex);
}

ND_RSA_CONTEX  *get_rsa_contex()
{
	return &__rsa_contex;
}

NDINT8 *get_pubkey_digest()
{
	return __rsa_digest ;
}
